package control;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

import parameter.ParameterItineraire;

public class StatRejet implements ParameterItineraire{
  
  HashMap<String,Long> listRejet;
  
  public StatRejet() {
    listRejet = new HashMap<String, Long>();
  }
  
  public void log(String motif) {
    if (listRejet.containsKey(motif)) {
      listRejet.put(motif, ((long)listRejet.get(motif))+1);
      return ;
    } 
    listRejet.put(motif, (long) 1);
  }
  
  public String toCSV() {
    StringBuffer buffer = new StringBuffer();
    for (Iterator<Entry<String, Long>> it = listRejet.entrySet().iterator(); it.hasNext();) {
      Entry<String, Long> entry = it.next();
      buffer.append(entry.getKey()).append(CSV_CELL_DELIMITER).append(entry.getValue()).append(CSV_LINE_DELIMITER);
    }
    return buffer.toString();
  }
  

}
